function PopupMenu(id,zIndex,dxShadow){var _this=this;this.menu_id=id;this.controlDiv=null;this.zIndex=100;this.dxShadow=3;this.menuItems=null;this.submenus=[];this.bDoHide=false;this.parentItem=null;this.parentMenu=null;this.submenuIndex=null;this.bHasSubmenus=false;this.OnClose=null;if(!isNaN(zIndex))this.zIndex=zIndex;if(!isNaN(dxShadow))this.dxShadow=dxShadow;this.Create=function(e,t){if(!isNaN(e))this.zIndex=e;if(!isNaN(t))this.dxShadow=t;var i=document.createElement("DIV");i.id=this.menu_id;i.className="bx-popup-menu";i.style.position="absolute";i.style.zIndex=this.zIndex;i.style.left="-1000px";i.style.top="-1000px";i.style.visibility="hidden";i.onclick=_this.PreventDefault;document.body.appendChild(i);i.innerHTML='<table cellpadding="0" cellspacing="0" border="0">'+'<tr><td class="popupmenu">'+'<table cellpadding="0" cellspacing="0" border="0" id="'+this.menu_id+'_items">'+"<tr><td></td></tr>"+"</table>"+"</td></tr>"+"</table>"};this.ClearItemsStyle=function(){var e=document.getElementById(this.menu_id+"_items");for(var t=0;t<e.rows.length;t++){var i=jsUtils.FindChildObject(e.rows[t].cells[0],"div");if(i&&i.className.indexOf("popupitemover")!=-1){i.className=i.className.replace(/\s*popupitemover/i,"");break}}};this.PopupShow=function(e){var t=document.getElementById(this.menu_id);if(!t){this.BuildItems();t=document.getElementById(this.menu_id)}this.ClearItemsStyle();setTimeout(function(){jsUtils.addEvent(document,"click",_this.CheckClick)},10);jsUtils.addEvent(document,"keypress",_this.OnKeyPress);var i=t.offsetWidth;var s=t.offsetHeight;e=jsUtils.AlignToPos(e,i,s);t.style.width=i+"px";t.style.visibility="visible";jsFloatDiv.Show(t,e["left"],e["top"],this.dxShadow,false);t.ondrag=jsUtils.False;t.onselectstart=jsUtils.False;t.style.MozUserSelect="none"};this.PopupHide=function(){for(var e=0,t=this.submenus.length;e<t;e++)if(this.submenus[e]&&this.submenus[e].IsVisible())this.submenus[e].PopupHide();if(this.parentMenu)this.parentMenu.submenuIndex=null;var i=document.getElementById(this.menu_id);if(i){jsFloatDiv.Close(i);i.style.visibility="hidden"}if(this.OnClose)this.OnClose();this.controlDiv=null;jsUtils.removeEvent(document,"click",_this.CheckClick);jsUtils.removeEvent(document,"keypress",_this.OnKeyPress)};this.CheckClick=function(e){for(var t=0,i=_this.submenus.length;t<i;t++)if(_this.submenus[t]&&!_this.submenus[t].CheckClick(e))return false;var s=document.getElementById(_this.menu_id);if(!s)return true;if(s.style.visibility!="visible")return true;var n=jsUtils.GetWindowScrollPos();var u=e.clientX+n.scrollLeft;var l=e.clientY+n.scrollTop;var m=parseInt(s.style.left);var o=parseInt(s.style.top);var r=m+parseInt(s.offsetWidth);var d=o+parseInt(s.offsetHeight);if(u>=m&&u<=r&&l>=o&&l<=d)return false;if(_this.controlDiv){var h=jsUtils.GetRealPos(_this.controlDiv);if(u>=h["left"]&&u<=h["right"]&&l>=h["top"]&&l<=h["bottom"])return false}_this.PopupHide();return true};this.OnKeyPress=function(e){if(!e)e=window.event;if(!e)return;if(e.keyCode==27)_this.PopupHide()};this.PreventDefault=function(e){if(!e)e=window.event;if(e.stopPropagation){e.preventDefault();e.stopPropagation()}else{e.cancelBubble=true;e.returnValue=false}return false};this.GetItemIndex=function(e){var t=_this.menu_id+"_item_";var i=parseInt(e.id.substr(t.length));return i};this.ShowSubmenu=function(item,bMouseOver,bDontShow){if(!item)item=this;var item_index=_this.GetItemIndex(item);if(bMouseOver==true){if(!_this.menuItems[item_index]["__time"])return;var dxTime=(new Date).valueOf()-_this.menuItems[item_index]["__time"];if(dxTime<500)return}var menu;if(!_this.submenus[item_index]){menu=new PopupMenu(_this.menu_id+"_sub_"+item_index);menu.Create(_this.zIndex+10,_this.dxShadow);menu.SetItems(_this.menuItems[item_index].MENU);menu.BuildItems();menu.parentItem=document.getElementById(_this.menu_id+"_item_"+item_index);menu.parentMenu=_this;menu.OnClose=function(){jsUtils.addEvent(document,"keypress",_this.OnKeyPress)};_this.submenus[item_index]=menu;if(_this.menuItems[item_index].ONMENUPOPUP)eval(_this.menuItems[item_index].ONMENUPOPUP)}else menu=_this.submenus[item_index];_this.submenuIndex=item_index;if(menu.IsVisible()||bDontShow==true)return;var item_pos=jsUtils.GetRealPos(item);var menu_pos=jsUtils.GetRealPos(document.getElementById(_this.menu_id));var pos={left:menu_pos["right"]-1,right:menu_pos["left"]+1,top:item_pos["bottom"]+1,bottom:item_pos["top"]};jsUtils.removeEvent(document,"keypress",_this.OnKeyPress);menu.controlDiv=item;menu.PopupShow(pos)};this.OnSubmenuMouseOver=function(){_this.OnItemMouseOver(this);var e=_this.GetItemIndex(this);if(!_this.menuItems[e]["__time"])_this.menuItems[e]["__time"]=(new Date).valueOf();var t=this;setTimeout(function(){_this.ShowSubmenu(t,true)},550)};this.OnItemMouseOver=function(e){if(_this.bHasSubmenus)_this.ClearItemsStyle();var t=e?e:this;t.className="popupitem popupitemover";if(_this.parentItem){_this.bDoHide=false;if(_this.parentItem.className!="popupitem popupitemover"){_this.parentMenu.ClearItemsStyle();_this.parentItem.className="popupitem popupitemover"}}if(_this.submenuIndex!=null){var i=_this.GetItemIndex(t);if(_this.submenuIndex!=i&&_this.submenus[_this.submenuIndex]){_this.submenus[_this.submenuIndex].bDoHide=true;setTimeout(function(){_this.HideSubmenu()},500)}}};this.OnSubmenuMouseOut=function(){var e=_this.GetItemIndex(this);_this.menuItems[e]["__time"]=null};this.OnItemMouseOut=function(){this.className="popupitem"};this.HideSubmenu=function(){if(_this.submenuIndex==null)return;if(_this.submenus[_this.submenuIndex].bDoHide!=true)return;_this.submenus[_this.submenuIndex].PopupHide()};this.SetItems=function(e){this.menuItems=e;this.submenus=[]};this.SetItemIcon=function(e,t){if(typeof e=="string"||e instanceof String){for(var i in this.menuItems){if(this.menuItems[i].ID&&this.menuItems[i].ID==e){this.menuItems[i].ICONCLASS=t;var s=document.getElementById(e);if(s){var n=jsUtils.FindChildObject(s,"div");if(n)n.className="icon "+t}break}}}else{var n=jsUtils.FindChildObject(jsUtils.FindChildObject(e,"td","gutter",true),"div");if(n){this.menuItems[this.GetItemIndex(e)].ICONCLASS=t;n.className="icon "+t}}};this.SetAllItemsIcon=function(e){for(var t=0,i=this.menuItems.length;t<i;t++){var s=document.getElementById(this.menu_id+"_item_"+t);var n=jsUtils.FindChildObject(jsUtils.FindChildObject(s,"td","gutter",true),"div");if(n){this.menuItems[t].ICONCLASS=e;n.className="icon "+e}}};this.BuildItems=function(){var e=this.menuItems;if(!e||e.length==0)return;var t=document.getElementById(this.menu_id);if(!t){this.Create();t=document.getElementById(this.menu_id)}t.style.left="-1000px";t.style.top="-1000px";t.style.width="auto";this.bHasSubmenus=false;var i=document.getElementById(this.menu_id+"_items");while(i.rows.length>0)i.deleteRow(0);var s=e.length;for(var n=0;n<s;n++){var u=i.insertRow(-1);var l=u.insertCell(-1);if(e[n]["CLASS"])u.className=e[n]["CLASS"];if(e[n]["SEPARATOR"]){l.innerHTML='<div class="popupseparator"><div class="empty"></div></div>'}else{var m='<div id="'+this.menu_id+"_item_"+n+'" class="popupitem"'+(e[n]["DISABLED"]!=true&&e[n]["ONCLICK"]?" "+(e[n]["MENU"]?"ondblclick":"onclick")+'="'+jsUtils.htmlspecialchars(e[n]["ONCLICK"])+'"':"")+">"+'	<div style="width:100%;"><table style="width:100% !important" cellpadding="0" cellspacing="0" border="0" dir="ltr">'+"		<tr>"+'			<td class="gutter"'+(e[n]["ID"]?' id="'+e[n]["ID"]+'"':"")+'><div class="icon'+(e[n]["ICONCLASS"]?" "+e[n]["ICONCLASS"]:"")+'"'+(e[n]["IMAGE"]?' style="background-image:url('+e[n]["IMAGE"]+');"':"")+"></div></td>"+'			<td class="item'+(e[n]["DISABLED"]==true?" disabled":"")+(e[n]["DEFAULT"]==true?" default":"")+'"'+(e[n]["TITLE"]?' title="'+e[n]["TITLE"]+'"':"")+">"+e[n]["TEXT"]+"</td>";if(e[n]["MENU"])m+='<td class="arrow"></td>';m+="		</tr>"+"	</table></div></div>";l.innerHTML=m;if(e[n]["DISABLED"]!=true){var o=jsUtils.FindChildObject(l,"div");if(e[n]["MENU"]){o.onclick=function(){_this.ShowSubmenu(this)};o.onmouseover=_this.OnSubmenuMouseOver;o.onmouseout=_this.OnSubmenuMouseOut;this.bHasSubmenus=true}else{o.onmouseover=function(){_this.OnItemMouseOver(this)};o.onmouseout=_this.OnItemMouseOut;if(e[n]["ONCLICK"]&&(e[n]["AUTOHIDE"]==null||e[n]["AUTOHIDE"]==true))jsUtils.addEvent(o,"click",function(){_this.PopupHide()})}}e[n]["__id"]=this.menu_id+"_item_"+n}}t.style.width=i.parentNode.offsetWidth};this.GetItemInfo=function(e){var t=jsUtils.FindChildObject(e,"td","item",true);if(t){var i="";var s=jsUtils.FindChildObject(jsUtils.FindChildObject(e,"td","gutter",true),"div");if(s.className.length>5)i=s.className.substr(5);return{TEXT:t.innerHTML,TITLE:t.title,ICON:i}}return null};this.GetMenuByItemId=function(e){for(var t=0,i=this.menuItems.length;t<i;t++)if(this.menuItems[t]["__id"]&&this.menuItems[t]["__id"]==e)return this;var s;for(var t=0,i=this.submenus.length;t<i;t++)if(this.submenus[t]&&(s=this.submenus[t].GetMenuByItemId(e))!=false)return s;return false};this.IsVisible=function(){var e=document.getElementById(this.menu_id);if(e)return e.style.visibility!="hidden";return false};this.ShowMenu=function(e,t,i,s,n){if(this.controlDiv==e){this.PopupHide()}else{if(this.IsVisible())this.PopupHide();if(t){this.SetItems(t);this.BuildItems()}e.className+=" pressed bx-pressed";var u=window.BX?BX.pos(e):jsUtils.GetRealPos(e);if(s){u["left"]+=s["left"];u["right"]+=s["right"];u["top"]+=s["top"];u["bottom"]+=s["bottom"]}else u["bottom"]+=2;if(i==true&&!jsUtils.IsIE()){var l=jsUtils.GetWindowScrollPos();u["top"]+=l.scrollTop;u["bottom"]+=l.scrollTop;u["left"]+=l.scrollLeft;u["right"]+=l.scrollLeft}this.controlDiv=e;this.OnClose=function(){e.className=e.className.replace(/\s*pressed bx-pressed/gi,"");if(n)n()};this.PopupShow(u)}}}
//# sourceMappingURL=popup_menu.map.js